
//***********************************************
//
//      Filename: pp5_7.java
//
//        Author: wwb
//        Mails: 1274860621@qq.com
//        Create: 2018-04-08 20:26:20
// Last Modified: 2018-04-08 20:26:20
//***********************************************
import java.util.Scanner;
import java.util.Random;

public class pp5_7 {

    public static void main(String[] args) {
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        int num5 = 0;
        String another;
        Scanner scan = new Scanner(System.in);
        System.out.println("Do you want to begin?");
        another = scan.nextLine();
        int ren;
        int compurter;
        String num;
        Random generator = new Random();

        while (another.equalsIgnoreCase("y")) {

            compurter = generator.nextInt(3);
            System.out.println("please enter your chance: ");
            ren = scan.nextInt();
            System.out.println("computer's chance: " + compurter);
            if (ren == 0 && compurter == 0) {
                num5++;
                System.out.println("It is tie.");
            } else if (ren == 0 && compurter == 1) {
                num1++;
                num4++;
                num5++;
                System.out.println("Congratulation! You are win!");
            } else if (ren == 0 && compurter == 2) {
                System.out.println("sorry,you are lost!");
                num2++;
                num3++;
                num5++;
            } else if (ren == 1 && compurter == 0) {
                System.out.println("sorry,you are lost!");
                num2++;
                num3++;
                num5++;
            } else if (ren == 1 && compurter == 1) {
                num5++;
                System.out.println("It is tie.");
            } else if (ren == 1 && compurter == 2) {
                num1++;
                num4++;
                num5++;
                System.out.println("Congratulation! You are win!");
            } else if (ren == 2 && compurter == 0) {
                num1++;
                num4++;
                num5++;
                System.out.println("Congratulation! You are win!");
            } else if (ren == 2 && compurter == 1) {
                System.out.println("sorry,you are lost!");
                num2++;
                num3++;
                num5++;
            } else if (ren == 2 && compurter == 2) {
                num5++;
                System.out.println("It is tie.");
            }


            System.out.print("\n玩家赢的局数： " + num1 + "\n玩家输的局数： " + num2 + "\n电脑赢的局数： " + num3 + "\n电脑输的局数： " + num4 + "\n总局数：" + num5);

            System.out.println();
            System.out.println("Do you want to continue to play(y/n)?: ");

            Scanner laowang = new Scanner(System.in);
            another = laowang.nextLine();


        }
    }
}
